<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="${contextPath}/resource/css/default.css" />
		<link rel="stylesheet" type="text/css" href="${contextPath}/resource/tree/zTreeStyle/zTreeStyle.css"  />
  		<script type="text/javascript" src="${contextPath}/resource/tree/jquery-1.4.2.js"></script>
 		<script type="text/javascript" src="${contextPath}/resource/tree/jquery.ztree-2.6.js"></script>
		<script language="JavaScript">
				var treeDb =${jsonTree};
				var zTree1;
				var setting;
					setting = {
						isSimpleData: true,
						treeNodeKey: "id",
						treeNodeParentKey: "pId",
								
						checkable: true,
						checkType: {"Y":"ps", "N":"s"},
						callback: {
								change:	zTreeOnChange
							}
						};
						$(document).ready(function(){
							refreshTree();
						});
				
				function zTreeOnChange(event, treeId, treeNode) {
					getCheckedNodesLength();
				}
				function refreshTree() {
					zTree1 = $("#radioAgencyId").zTree(setting, treeDb);
					zTree1.selectNode({"id":1});
					getCheckedNodesLength();
				}
				function getCheckedNodesLength() {
					var tmp = zTree1.getCheckedNodes();
					var rolegroupRoleids = "";
					
					for (var i=0; i<tmp.length; i++) {
						if(i == tmp.length-1){
							rolegroupRoleids += tmp[i].id;
						}else{
							rolegroupRoleids += tmp[i].id+",";
						}
					}
					 document.getElementById("rolegroup.roleids").value =rolegroupRoleids;
				}
				function validate(nameid, valiID) {
					var obj = document.getElementById(nameid).value;
					obj = obj.replace(/(^\s*)|(\s*$)/g, "");// 去掉前后空格
					if ("" == obj) {
						document.getElementById(valiID).innerHTML = "\u89D2\u8272\u540D\u4E0D\u80FD\u4E3A\u7A7A";
						return false;
					} else {
						document.getElementById(valiID).innerHTML = " ";
						return true;
					}
				}
				function isSubmit(nameid, valiID){
					var xObject = new Boolean(true);
					if (xObject == validate(nameid, valiID)) {
						return true;
					} else {
						return false;
					}
				}
		</script>
	</head>

	<body >
	<s:form action="rolegroupAction_update.do" method="post" namespace="/" onsubmit="return isSubmit('rolegroup.name','resultRrolegroupName')">
			<table class="menu_table">
				<tr>
					<th>
						<a href="rolegroupAction_list.do">角色管理</a>&gt;&gt;修改角色
					</th>
				</tr>
			</table>
				<div class="listtable">
<div class="secondDiv">
			<table class="form_table">
				<tr>
					<th width="22%">
						角色名称
						<s:hidden name="rolegroup.id" value="%{rolegroup.id}" />
					</th>
					<td width="78%">
						<s:textfield name="rolegroup.name" value="%{rolegroup.name}" id="rolegroup.name"
							size="30" maxlength="30"
							onblur="validate('rolegroup.name','resultRrolegroupName')" />
						<span class="txtblue" id="resultRrolegroupName">*</span>
					</td>
				</tr>
				<tr>
					<th>是否是有效 </th>
					<td>
					 <s:select name="rolegroup.isactivate" list="#{'1':'是','0':'否'}"></s:select>
					</td>
				</tr>
				<tr>
					<th>是否是系统默认 </th>
					<td>
					 <s:select name="rolegroup.isSystem" list="#{'1':'是','0':'否'}"></s:select>
					</td>
				</tr>
				<tr>
					<th>创建人</th>
					<td>
					<s:textfield name="rolegroup.userId" value="%{rolegroup.userId}" id="rolegroup.userId" size="30" maxlength="50"/>
					</td>
				</tr>
				<tr>
					<th>描述</th>
					<td>
					<s:textfield name="rolegroup.descriptions" value="%{rolegroup.descriptions}" id="rolegroup.descriptions" size="100" maxlength="100"/>
					</td>
				</tr>
				<tr>
					<th>拥有权限</th>
					<td>
					<s:hidden name="rolegroup.roleids" value="%{rolegroup.roleids}" id="rolegroup.roleids"></s:hidden>
					    <div class="zTreeDemoBackground">
							<ul id="radioAgencyId" class="tree"></ul>
						</div>
					</td>
				</tr>
			</table>
			<div style="margin-top: 20px; margin-left: 30px;">
				<s:token></s:token>
				<input type="submit" value="修改" />&nbsp;&nbsp;&nbsp;
				<input type="button"	onclick="javascript:location='rolegroupAction_list.do'"
					value="返回列表" />&nbsp;&nbsp;&nbsp;
					 <input type="reset" value="还原" />
			</div>
			<br />
			</div>
			</div>
		</s:form>
	</body>
</html>
